package com.hqm.common.utils;

/**
 * @author : fengSir
 * @date : 16:08 2021/11/12
 */
public interface RedisKeyUtil {
    static final long serialVersionUID = -526324944915280489L;
    static final String SPILT=":";
    static final String PREFIX_ITEM_TIME="kill:time:killId";
    static final String PREFIX_MD5_USER_KEY="kill:md5:user";
    static final String PREFIX_KILL_SUCCESS_KEY="kill:order:user";
    static final String PREFIX_KILL_KILLID_SUCCESS_KEY="kill:order:killId";
    static final String PREFIX_KILL_STOCK="kill:stock:item";
    static final String PREFIX_ITEM_KILL="kill:killId";
    static final String PREFIX_ITEM="kill:itemId";
    static final String PREFIX_USER_MENU="kill:menu";  //权限
    static final String PREFIX_USER="kill:user";  //用户

    //获取某个商品秒杀活动的时间 String
    public static String getKillTimeKey(int killId){
        return PREFIX_ITEM_TIME+SPILT+killId;
    }
    //获取某个用户的MD5盐值 String
    public static String getMd5UserKey(String md5Key){
        return PREFIX_MD5_USER_KEY+SPILT+md5Key;
    }
    //获取生成订单成功的用户 Hash
    public static String getKillSuccessKey(int userId){
        return PREFIX_KILL_SUCCESS_KEY+SPILT+userId;
    }
    //获取生成订单对应的KillID,用来保存抢购成功的秒杀活动id
    public static String getKillIDSuccessKey(int killId){
        return PREFIX_KILL_KILLID_SUCCESS_KEY+SPILT+killId;
    }
    //获取秒杀活动的库存 List
    public static String getKillStockKey(int itemId, int killId){
        return PREFIX_KILL_STOCK+SPILT+itemId+SPILT+killId;
    }
    //获取秒杀活动 Object
    public static String getItemKillKey(int killId){
        return PREFIX_ITEM_KILL+SPILT+killId;
    }
    //获取秒杀的商品 Object
    public static String getItemKey(int itemId){
        return PREFIX_ITEM+SPILT+itemId;
    }
    //获取用户的权限 List
    public static String getUserMenuKey(String username){
        return PREFIX_USER_MENU+SPILT+username;
    }
    //获取用户 Object
    public static String getUserKey(String username){
        return PREFIX_USER+SPILT+username;
    }

}
